package tests.kr.pe.mkseo.data;


import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;

import junit.framework.Assert;
import junit.framework.TestCase;
import kr.pe.mkseo.data.Account;
import kr.pe.mkseo.data.Category;
import kr.pe.mkseo.data.Record;

public class AccountTest extends TestCase {
	
	/**
	 * Tests if balance records for an account is maintained in sorted order of 
	 * date.
	 */
	public void testRecordSort() {
		Calendar c1 = Calendar.getInstance();
		c1.set(2001, 1, 1);
		Record b1 = new Record(c1, new BigDecimal("100"));
		
		Calendar c2 = Calendar.getInstance();
		c2.set(2002, 2, 2);
		Record b2 = new Record(c2, new BigDecimal("200")); 
		
		Account accnt = new Account(null, null);
		accnt.AddBalanceRecord(b1);
		accnt.AddBalanceRecord(b2);
		
		Iterator<Record> i;
		i = accnt.UnmodifiableIterator();
		
		// New one comes first.
		Assert.assertEquals(b2, i.next());
		Assert.assertEquals(b1, i.next());
		Assert.assertFalse(i.hasNext());
	}
}
